function mnrelcontpag() {
	$('#content').load("html/mantercontaspagar.html #pnlRelContPag", function() { 
		$('#dt_ini').mask('99/99/9999');
		$('#dt_fim').mask('99/99/9999');

		$("#pnlRelParams").dialog({
		    modal: true,
		    buttons: {
		        Ok: function() {
		        	var dt_ini = $('#dt_ini').val();
		        	var dt_fim = $('#dt_fim').val();
		        	var tipo   = $('input:radio[name=contas]:checked').val();
		        	var titulo = "Relatório de Contas ";
		        	
		        	if (tipo == "ap") {
		        		titulo += "a Pagar";
		        	} else if (tipo == "pp") {
		        		titulo += "a Pagar Pendentes";
		        	} else {
		        		titulo += "Pagas";
		        	}

		        	sendForm('#frmRelParams', function(data) {
		        		var x = open("html/relcontpag.html", titulo, "top=20, left=10, width=1100, height=600");
		        		x.focus;
		        		x.onload = function() {
		        			var lblData = x.document.getElementById('lblPrintDate');
		        			var dthr = new Date().toLocaleString().split(" ");
		        			$(lblData).text(dthr[0] + " às " + dthr[1] + " ");
		        			$(x.document.getElementById('pTitulo')).html(titulo);
		        			
		        			if (tipo == "pp") {
		        				$(x.document.getElementById('pPeriodo')).remove();
		        			} else {
			        			lblData = x.document.getElementById('lblDtIni');
			        			$(lblData).text(dt_ini);
			        			lblData = x.document.getElementById('lblDtFim');
			        			$(lblData).text(dt_fim);
		        			}

		        			var tbBody = x.document.getElementById('tbBody');
		        			var detail = x.document.getElementById('trHead');
		        			var tr = null;
		        			
		        			$(data.Records).each(function(index, ctp) {
		        				tr = $(detail).clone();
		        				$(tr).find('#tdData').html(ctp.data);
		        				$(tr).find('#tdHistorico').html(ctp.historico);
		        				$(tr).find('#tdVr').html(ctp.valor);
			        			$(tbBody).append(tr);
		        			});
		        			$(x.document.getElementById('btnPrint')).click(function() {
		        				$(this).hide();
		        				x.print();
		        				$(this).show();
		        			});
		        			$(x.document.getElementById('lblTotalRec')).text(data.TotalRecordCount);
		        		};
		        	});
		            $(this).dialog("close");
		        },
		        Cancelar: function() {
		            $(this).dialog("close");
		        }
		    },
		    close: function() {
	            $(this).remove();
		    }
		});
	});
}